﻿
@{ViewBag.Title = "角色添加";  }
<form class="layui-form" action="">
    <div class="mainBox">
        <div class="main-container">
            <div class="main-container">
                <div class="layui-form-item">
                    <label class="layui-form-label">分类名</label>
                    <div class="layui-input-block">
                        <input type="text" name="CategoryName" required lay-verify="required" placeholder="请输入分类名" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">描述</label>
                    <div class="layui-input-block">
                        <input type="text" name="Description" required lay-verify="required" placeholder="请输入描述" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit="" lay-filter="mc-save">
                            <i class="layui-icon layui-icon-ok"></i>
                            提交
                        </button>
                        <button type="reset" class="pear-btn pear-btn-sm">
                            <i class="layui-icon layui-icon-refresh"></i>
                            重置
                        </button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</form>

@section script{
    <script>
        layui.use(['form', 'layer'], function () {
            var form = layui.form;
            var layer = layui.layer;
            var $ = layui.jquery;
            form.on('submit(mc-save)', function (data) {
                //layer.msg(JSON.stringify(data.field));
                $.post("/mcategory/add", data.field, function (res) {
                    if (res.success) {
                        layer.msg(res.msg, { icon: 1, time: 1000 }, function () {
                            parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
                            parent.layui.table.reload("mc-table");
                        });
                    } else {
                        layer.msg(result.msg, { icon: 2, time: 1000 });
                    }

                })
                return false;
            });
        });
    </script>
}